package com.lwm.controller;

import com.lwm.domain.ResponseResult;
import com.lwm.domain.SalesReturn;
import com.lwm.dto.SalesReturnDto;
import com.lwm.service.SalesReturnService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/salesReturn")
public class SalesReturnController {

    @Resource
    private SalesReturnService salesReturnService;

    /**
     * 添加
     *
     * @param salesReturn 销售退货
     * @return {@link ResponseResult}
     */
    @PostMapping
    public ResponseResult save(@RequestBody SalesReturn salesReturn) {
        return salesReturnService.save(salesReturn);
    }

    /**
     * 更新
     *
     * @param salesReturn 销售退货
     * @return {@link ResponseResult}
     */
    @PutMapping
    public ResponseResult update(@RequestBody SalesReturn salesReturn) {
        return salesReturnService.update(salesReturn);
    }

    /**
     * 删除
     *
     * @param ids ids
     * @return {@link ResponseResult}
     */
    @DeleteMapping("/{ids}")
    public ResponseResult remove(@PathVariable("ids")List<Long> ids) {
        return salesReturnService.removeBatch(ids);
    }

    /**
     * 收到分页
     *
     * @param salesReturnDto 销售退货dto
     * @return {@link ResponseResult}
     */
    @PostMapping("/page")
    public ResponseResult getPage(@RequestBody SalesReturnDto salesReturnDto) {
        return salesReturnService.getPage(salesReturnDto);
    }
}
